/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author: WJW
 * Date: 2024-07-31
 * Time: 16:20
 */


//2.实现Run那别了，重写run
class MyThread2 implements Runnable{
    @Override
    public void run() {
        while(true){
            System.out.println("hello runnable");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class ThreadDemo2 {
    public static void main(String[] args) {
        //Runnable runnable = new MyThread2();
        //Thread t = new Thread();
        Thread t = new Thread(new MyThread2());
        t.start();
        while (true){
            System.out.println("hello main");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
